package org.zfes.snowier.zbss.xzy.router.device;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.device.model.DeviceType;
import org.zfes.snowier.zbss.xzy.biz.device.service.IDeviceTypeService;
import org.zfes.snowier.zbss.xzy.device.DeviceTypeDto;
@Controller 
@RequestMapping("/manger/deviceType")
public class DeviceTypeController implements BaseController {

	
	@Autowired
	private IDeviceTypeService deviceTypeService;
	
    @RequestMapping(value="/loadDeviceTypeDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadDeviceTypeDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  deviceTypeService.loadDeviceTypeDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
    
    @RequestMapping(value="/loadAllDeviceType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAllDeviceType(){
    	List<DeviceType> deviceTypeList  =  deviceTypeService.loadAllDeviceType(Byte.valueOf("1"));
	    return ajaxQuery("result", deviceTypeList);
    }
    
    @RequestMapping(value="/loadAllDeviceTypeModel", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAllDeviceTypeModel(){
    	List<DeviceTypeDto> deviceTypeMdoelList  =  deviceTypeService.loadAllDeviceTypeModel(Byte.valueOf("1"));
	    return ajaxQuery("result", deviceTypeMdoelList);
    }
    
    
    @RequestMapping(value="/createDeviceType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createDeviceType(DeviceType deviceType){
		deviceTypeService.createDeviceType(deviceType);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
    @RequestMapping(value="/loadDeviceType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadDeviceType(Long id){
		Optional<DeviceType> ops = deviceTypeService.loadDeviceTypeById(id);
		return ajaxQuery("deviceType",ops);
    }
	
    @RequestMapping(value="/updateDeviceType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateDeviceType(DeviceType deviceType){
		deviceTypeService.updateDeviceType(deviceType);
		return ajaxDoneSuccess("数据操作成功 ");
    }
    
    @RequestMapping(value="/setDeviceTypeStatus", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object setDeviceTypeStatus(Long id,Byte status){
		deviceTypeService.setDeviceTypeStatus(id, status);
		return ajaxDoneSuccess("数据操作成功 ");
    }
    
}